class CartController < ApplicationController
  before_filter :initialize_cart
    
  def add
    @artwork = Artwork.find(params[:id])
    if @artwork.quantity == nil
      @artwork.quantity = 0
    else
      @artwork.quantity = @artwork.quantity - 1
    end
    @artwork.save
    @item = @cart.add(params[:id])
  end
    
  def remove
    @artwork = Artwork.find(params[:id])
    @item = @cart.remove(params[:id])
  end
  
  def clear
    @cart.cart_items.destroy_all
  end
  
end
